package wiki.kaizen.cloud.security.session.support;

import lombok.Setter;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import wiki.kaizen.cloud.security.session.support.listener.LogoutListener;

import java.util.List;

/**
 * 重写 安全管理器 以运行 自定义监听器 比如调用subject.logout()时 触发指定监听器
 * @author xeepoo
 * */
public class KaizenSecurityManager extends DefaultWebSecurityManager {

    @Setter
    private List<LogoutListener> logouts;


    @Override
    public void logout(Subject subject) {
        if (logouts != null &&logouts.size()>0){
            logouts.forEach(
                out->out.logout(subject)
            );
        }
        super.logout(subject);
    }
}
